//----------------------------产品
const String productQuery = '''
  edges{
    node{
      databaseId
      name
      averageRating
      slug
      sku
      image{
        sourceUrl
      }
      ... on SimpleProduct{
        price
        regularPrice
        stockStatus
        galleryImages {
          nodes {
            sourceUrl
          }
        }
      }
      ... on VariableProduct{
        price
        regularPrice
        stockStatus
        galleryImages {
          nodes {
            sourceUrl
          }
        }
      }
    }
  }
''';

const String PRODUCT_QUERY = '''
{
  newProducts:products(first: 10, where: {orderby: {field: DATE, order: DESC}}) {
    $productQuery
  },
  featuredProducts: products(first: 10, where: {featured: true}) {
    $productQuery
  },
  bestSellingProducts: products(first: 10, where: {orderby: {field: TOTAL_SALES, order: DESC}}) {
    $productQuery
  }
}
''';

////////////////////////
// 定义 GraphQL 查询语句常量 后面三个     Blog
const String GET_POSTS_QUERY = '''
  query GetPosts(\$first: Int, \$after: String, \$categoryName: String) {
    posts(first: \$first, after: \$after, where: { categoryName: \$categoryName, status: PUBLISH }) {
      pageInfo {
        hasNextPage
        endCursor
        offsetPagination {
          total
        }
      }
      nodes {
        databaseId
        slug
        title
        date
        content
        commentCount
        featuredImage {
          node {
            sourceUrl
          }
        }
        author {
          node {
            name
            databaseId
          }
        }
        categories {
          nodes {
            name
            slug
          }
        }
      }
    }
  }
''';

//----------------------搜索
const String SEARCH_QUERY = '''
  query SearchQuery(\$search: String!) { 
    products(where: {search: \$search}, first: 10) { 
      edges {
        node {
          ... on VariableProduct {
            id
            name
            price
            slug
            image {
              sourceUrl
              slug
            }
            averageRating
          }
        }
      }
    }
    posts(where: {search: \$search}, first: 10) { 
      nodes {
        databaseId
        slug
        title
        date
        content
        commentCount
        featuredImage {
          node {
            sourceUrl
            slug
          }
        }
        author {
          node {
            name
            databaseId
          }
        }
        categories {
          nodes {
            name
            slug
          }
        }
      }
    }
  }
''';
